import ReactDOM from "react-dom/client";
import { createBrowserRouter, RouterProvider } from "react-router-dom";
import { routes } from "./routes";
import "@ant-design/v5-patch-for-react-19";
export * from "./global";

const router = createBrowserRouter(routes);
const rootEl = document.getElementById("root");
if (rootEl) {
  const root = ReactDOM.createRoot(rootEl);
  console.debug(routes, router);
  root.render(<RouterProvider router={router} />);
} else {
  console.error("无法找到 #root 元素");
  // 可选：创建备用元素
  const backupRoot = document.createElement("div");
  document.body.appendChild(backupRoot);
  ReactDOM.createRoot(backupRoot).render(<div>无法找到挂载点</div>);
}
